/*******************************************************************************
"SCARCITY WITHOUT LEVIATHAN: The Violent Effects of Cocaine Supply Shortages
in the Mexican Drug War"
J.C. Castillo, D. Mejia, P. Restrepo
*********************************************************************************

This do file produces:
TABLE 3: "Additional time series estimates of the effect of cocaine seizures in
Colombia on the homicide rate in Mexican municipalities"

The table presents estimates of the effect of cocaine seizures in Colombia on violence
in different groups of municipalities in Mexico, it includes extra leads/lags of
cocaine seizures compared to Table 2

Before running: set the path to current folder at line 23
*******************************************************************************/

clear all
set matsize 5000
set more off

*Set local folder
local folder /*SET THE PATH TO CURRENT FOLDER HERE*/

*Set working directory
cd `folder'
use dta\CastilloMejiaRestrepo.dta
tab year if  timeTS >= ym(2006,12), gen(yy)

*mexican seasons
gen rainy=(month>=5 & month<=9)
gen hurricane=((month>=6 & month<=11))

*us seasons
gen spring=(month>=3 & month<=5)
gen summer=(month>=6 & month<=8)
gen fall=(month>=9 & month<=11)

*quarters
gen quart1=(month>=1 & month<=3)
gen quart2=(month>=4 & month<=6)
gen quart3=(month>=7 & month<=9)
gen quart4=(month>=10 & month<=12)

*month effects
tab month, gen(mm)

local tscontrols t t2 t3  yy2 yy3 yy4 yy5 

gen homicides=homSIMBAD
gen supplyShock=log(cocaincCol)


/****************************************************
******* Time series estimates - All Mexico  *********
******* Columns 1-4 					  ***********
****************************************************/
preserve
collapse `tscontrols' supplyShock unemp IGAE (sum) homicides poblacion, by(timeTS)

/*Create homicide rate*/
gen tasa = homicides/poblacion * 100000 * 12
gen log_tasa=log(tasa)	
tsset timeTS

/*Analyze serial correlation of the series:*/ 
*Lags of the homicide rate *
reg log_tasa l(1/3).log_tasa  supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e1

*Lags of seizure shock*
reg log_tasa l(0/3).supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e2

*Leads of seizure shock*
reg log_tasa f(1/3).supplyShock supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e3

*Lags and leads of seizure shock*
reg log_tasa f(1/3).supplyShock l(0/3).supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e4
restore

/****************************************************
***** Time series estimates -  Quintiles 1 and2 *****
******* Columns 5-8 					  ***********
****************************************************/
preserve
keep if q12==1
collapse `tscontrols' supplyShock unemp IGAE (sum) homicides poblacion, by(timeTS)

/*Create homicide rate*/
gen tasa = homicides/poblacion * 100000 * 12
gen log_tasa=log(tasa)	
tsset timeTS

/*Analyze serial correlation of the series:*/ 
*Lags of the homicide rate *
reg log_tasa l(1/3).log_tasa  supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e5

*Lags of seizure shock*
reg log_tasa l(0/3).supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e6

*Leads of seizure shock*
reg log_tasa f(1/3).supplyShock supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e7

*Lags and leads of seizure shock*
reg log_tasa f(1/3).supplyShock l(0/3).supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e8
restore


/****************************************************
******* Time series estimates -  Quintile 1  ********
******* Columns 5-8 					  ***********
****************************************************/
preserve
keep if q1==1
collapse `tscontrols' supplyShock unemp IGAE (sum) homicides poblacion, by(timeTS)

/*Create homicide rate*/
gen tasa = homicides/poblacion * 100000 * 12
gen log_tasa=log(tasa)	
tsset timeTS

/*Analyze serial correlation of the series:*/ 
*Lags of the homicide rate *
reg log_tasa l(1/3).log_tasa  supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e9

*Lags of seizure shock*
reg log_tasa l(0/3).supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e10

*Leads of seizure shock*
reg log_tasa f(1/3).supplyShock supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e11

*Lags and leads of seizure shock*
reg log_tasa f(1/3).supplyShock l(0/3).supplyShock `tscontrols' if  timeTS >= ym(2006,12), robust
estimates store e12
restore

estout e1 e2 e3 e4 e5 e6 e7 e8 e9 e10 e11 e12 using Tables/Table3.tex, style(tex) ///
varlabels(L.log_tasa "log homicide rate $ t-1$" L2.log_tasa "log homicide rate $ t-2$" ///
L3.log_tasa "log homicide rate $ t-3$" F3.supplyShock "log of seizures in Colombia $ t+3$" ///
F2.supplyShock "log of seizures in Colombia $ t+2$" F.supplyShock "log of seizures in Colombia $ t+1$" ///
supplyShock "log of seizures in Colombia $ t$" L.supplyShock "log of seizures in Colombia $ t-1$" ///
L2.supplyShock "log of seizures in Colombia $ t-2$" L3.supplyShock "log of seizures in Colombia $ t-3$" ) ///
 cells(b(star fmt(%9.3f)) se(par fmt(%9.3f))) stats(N r2 , fmt(%7.0f  %7.3f) labels("Observations" "R-squared")) ///
 collabels(none)  keep(L.log_tasa L2.log_tasa L3.log_tasa F3.supplyShock F2.supplyShock F.supplyShock supplyShock L.supplyShock L2.supplyShock L3.supplyShock) ///
 order(L.log_tasa L2.log_tasa L3.log_tasa F3.supplyShock F2.supplyShock F.supplyShock supplyShock L.supplyShock L2.supplyShock L3.supplyShock)  ///
 starlevels(\$^{*}\$ .1 \$^{**}\$ .05 \$^{***}\$ .01) nolabel replace mlabels(none)


